ComponentOne PdfViewer for UWP
Key Features / Asynchronous Loading
In This Topic
    Asynchronous Loading
    In This Topic

    For better performance you can have the C1PdfViewer control load documents in the background asynchronously. Using the .NET await keyword, you can easily call asynchronous methods. To open a file selected by the user asynchronously, complete the following code:

    Note: In order to use the ‘await’ keyword, the event or method in which the call is made from must be marked as asynchronous by using the ‘async’ keyword.
    C#
    Copy Code
    FileOpenPicker openPicker = new FileOpenPicker();
    openPicker.FileTypeFilter.Add(".pdf");
    StorageFile file = await openPicker.PickSingleFileAsync();
    if (file != null)
    {
      Stream stream = await file.OpenStreamForReadAsync();
      await pdfViewer.LoadDocumentAsync(stream);
    }